<%-- 
    Document   : test
    Created on : Mar 21, 2013, 12:43:02 PM
    Author     : Max
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
 <head>
  <script type="application/javascript">
      
      function OnClickGreetings()
        {
               var msg='<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">'+
                '<S:Header/>'+
                '<S:Body>'+
                    '<ns2:getPic xmlns:ns2="http://WebServiceStub.com/"/>'+
                '</S:Body>'+
            '</S:Envelope>';
                $.ajax({
                url:"http://localhost:8080/WebServiceStub/WebServiceStub",
                type: "POST",
                dataType: "xml",
                data: msg,
                contentType: 'text/xml; charset="utf-8"',
                success:function(result){
                    OnSucsessHelloWorld(result);
                      //alert( $(result).find("return").text());
                },
                 error: function(){alert("Error: Something went wrong");}									 
                });
                alert("asd");
        }

        function OnSucsessHelloWorld(result){
                    var res=[];
                    $(result).find("return").each(function () {
                           res.push( $(this).text()) ;
                    });
                    alert(res[0]);
        }
      
      
    function draw() {
      var canvas = document.getElementById('canvas');
      if (canvas.getContext) {
        var ctx = canvas.getContext("2d");
 
        ctx.fillStyle = "rgb(200,0,0)";
        ctx.fillRect (10, 10, 55, 50);
        
        ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
        ctx.fillRect (30, 30, 55, 50);
      }
    }
  </script>
 </head>
 <body onload="draw();">
   <canvas id="canvas" width="56" height="54"></canvas>
   <button onclick="OnClickGreetings()">getPic</button>
 </body>
</html>